<?php

require_once ("../src/Money.class.php");
require_once ("../src/PorteMonnaie.class.php");
require_once ("../src/MoneyExceptions.php");

class PorteMonnaieTestCase extends PHPUnit_Framework_TestCase
{
	private static $zeroEuro ;
    
    public static function setUpBeforeClass() {
		PorteMonnaieTestCase::$zeroEuro=MoneyFactory::getDefaultFactory()->createMoney(0,"EUR");
	}

	public function testAdd() {

		$f16eur = MoneyFactory::getDefaultFactory()->createMoney(16,"EUR");
        $this->assertTrue(PorteMonnaie::add(PorteMonnaieTestCase::$zeroEuro,$f16eur)->equals(MoneyFactory::getDefaultFactory()->createMoney(16,"EUR")));
	} 

	public function testRemove() {

		$f16eur = MoneyFactory::getDefaultFactory()->createMoney(16,"EUR");
		$f2eur = MoneyFactory::getDefaultFactory()->createMoney(2,"EUR");

        $this->assertTrue(PorteMonnaie::suppr($f16eur,$f2eur)->equals(MoneyFactory::getDefaultFactory()->createMoney(14,"EUR")));
	} 

	public function testRemoveMore() {

		$f16eur = MoneyFactory::getDefaultFactory()->createMoney(16,"EUR");

		try{
            
			PorteMonnaie::suppr(PorteMonnaieTestCase::$zeroEuro,$f16eur);
		}

		catch (UnexistingCurrencyException $e) {

		} 
		catch (NotEnoughMoneyException $e) {
			
		}

	} 


/*
*
*	TEST MULTI DEVISES
*
*/

	public function testMultiDevisesAdd() {

		try{
            
				$f16eur = MoneyFactory::getDefaultFactory()->createMoney(16,"EUR");
				$f16dollar = MoneyFactory::getDefaultFactory()->createMoney(16,"USD");


			$this->assertTrue(PorteMonnaie::add($f16eur,$f16dollar)->equals(MoneyFactory::getDefaultFactory()->createMoney(32,"EUR")));
			$this-fail();
		}

		catch (UnexistingCurrencyException $e) {

		} 
		catch (IncompatiblesCurrenciesException $e) {
			
		}

	} 

	public function testMultiDevisesRemove() {

		try{
            
				$f16eur = MoneyFactory::getDefaultFactory()->createMoney(16,"EUR");
				$f6dollar = MoneyFactory::getDefaultFactory()->createMoney(6,"USD");


			$this->assertTrue(PorteMonnaie::suppr($f16eur,$f6dollar)->equals(MoneyFactory::getDefaultFactory()->createMoney(10,"EUR")));
			$this-fail();
		}

		catch (UnexistingCurrencyException $e) {

		} 
		catch (IncompatiblesCurrenciesException $e) {
			
		}

	} 

}
?>
